import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		baseUrl: 'https://api.jupiaoer.top',
		// baseUrl: 'http://t.api.yivibao.com', //测试域名
		imgUrl: 'https://img.piaohenduo.com/', //图片域名
		windowHeight: 0,//屏幕高度
		topHeight: 0,//手机菜单高度
		uInfo: '',//用户信息
		locCity: '',//定位信息
		chooseLoc: '',//选择地址
		code:'',//全局code
		windowHeiAndWid:{},
		isChangeCondition:false, // 是否改变影院的选择条件
		seatCopyInfo:{},//seatCopy页面需要的数据
		userSetting:{},//用户授权状态
		showPrivacy:false,//弹隐私弹窗的时机
	},
	mutations: {
		// 改变影院的选择条件
		setChooseCondition(state,value){
			state.isChangeCondition = value
		},
		
		setWidthAndHeight(state,heiAndWid){
			state.windowHeiAndWid = heiAndWid
		},
		setWindowHeight(state, height) {
			state.windowHeight = height
		},
		setTopHeight(state, height) {
			state.topHeight = height
		},
		setUserInfo(state, info) {
			state.uInfo = info
		},
		setLocCity(state, city) {
			state.locCity = city
		},
		setChooseLoc(state, choose) {
			state.chooseLoc = choose
		},
		setCode(state, choose) {
			state.code = choose
		},
		setTel(state, choose) {
			state.uInfo.tel = choose
		},
		setSeatCopyInfo(state,data){
			state.seatCopyInfo = data
		},
		setUserSetting(state,data){
			state.userSetting = data
		},
		handlerPrivacy(state,data){
			state.showPrivacy = data
		}
	},
	getters:{
		nowLoc(state){
			let loc = state.locCity || (uni.getStorageSync('loc')==''?null:JSON.parse(uni.getStorageSync('loc')))
			let chooseloc = state.chooseLoc || (uni.getStorageSync('chooseloc')==''?null:JSON.parse(uni.getStorageSync('chooseloc')))
			if(loc==null)return chooseloc
			return loc.update>=chooseloc.update_time ?loc:chooseloc
			
			
		}
	}
})
export default store //导出store对象
